package com.travel.common.persitence;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.travel.common.util.AbstractBean;

public class HibernateUtil extends AbstractBean {
	private static final long serialVersionUID = 5280020698931861669L;

	public void closeSession(Session session) {
		if (session != null)
			try {
				session.close();
			} catch (HibernateException he) {
				he.printStackTrace();
			}
	}

	public Session getSession() {
		SessionFactory sessionFactory = (SessionFactory) getBean("sessionFactory");
		return sessionFactory.openSession();
	}
}